package com.jxzn.locust.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jxzn.locust.model.Manager;

@Repository
public interface ManagerRepository extends AbstractRepository<Manager> {
    Manager findByAccount(String account);

    @Modifying
    @Query("update Manager set password=:password where id=:id")
    int resetPassword(@Param("id") int id, @Param("password") String password);

    @Modifying
    @Query("update Manager set lastLoginTime=now() where id=:id")
    int login(@Param("id") int id);

    @Modifying
    @Query("update Manager set effect=:effect where id=:id")
    int updateStatus(@Param("id") int id, @Param("effect") boolean effect);

    List<Manager> findByRoleId(String roleId);
}
